/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 * Description
 *
 * User: jinchen
 * Date: Jun 7, 2003
 * Time: 11:13:15 AM
 */
package edu.psu.geovista.app.pcp.toolkits;

import javax.swing.*;

public class Validator {

    public static boolean isValidString(String s) {
        if(s!=null&&s.length() >0)
            return true;
        else
            return false;
    }

     public static boolean isValidArray(Object[] a) {
        if(a!=null&&a.length >0)
            return true;
        else
            return false;
    }
    /**
     *
     * @param sv
     * @param c
     * @return
     */
    public static float getNumberByText(String sv, JComponent c){
        float value=Float.NaN;
        if (sv==null) return 0;
        try {
                    value = Float.valueOf(sv).floatValue();
                    return value;
                    //System.out.println(tickMin.getText());
                } catch (NumberFormatException e) {
                    JOptionPane.showMessageDialog(c,"Must enter a number ");
                }
        return value ;
    }
}
